﻿using DotnetSpider.Core;
using DotnetSpider.Core.Pipeline;
using Spider_Demo.Common;
using Spider_Demo.Models;
using System;
using System.Collections.Generic;
using System.Text;

namespace Spider_Demo.Pipeline
{
    class MM131_Pipeline : BasePipeline
    {
        public override void Process(IEnumerable<ResultItems> resultItems, ISpider spider)
        {
            foreach (var resultItem in resultItems)
            {
                foreach (var img in resultItem.Results["MM_ImgList"] as List<MM_Images>)
                {
                    HttpHelper.SaveFile(img.Thumbnail_ImgUrl, img.ImgTitle, $"MM131/{img.ImgType}/{img.ImgTitle}", "https://www.mm131.net", out var status);
                    Console.WriteLine($"【MM131】封面“{img.ImgTitle}.jpg”的下载结果：{status}");
                    foreach (var item in img.ImgInfo)
                    {
                        HttpHelper.SaveFile(item.HD_ImgUrl, item.ImgName, $"MM131/{img.ImgType}/{img.ImgTitle}", "https://www.mm131.net", out var resule);
                        Console.WriteLine($"【MM131】“{item.ImgName}.jpg”的下载结果：{resule}");
                    }

                }
            }
        }
    }
}
